import mongoose, { Schema, Document } from 'mongoose';

export interface IExpenseType extends Document {
  name: string;
  code: string;
  description?: string;
  isDefault: boolean;
  userId?: mongoose.Types.ObjectId; // 用户自定义类型可选
}

const ExpenseTypeSchema = new Schema<IExpenseType>({
  name: { type: String, required: true },
  code: { type: String, required: true, unique: true },
  description: { type: String },
  isDefault: { type: Boolean, default: false },
  userId: { type: Schema.Types.ObjectId, ref: 'User' },
});

export const ExpenseType = mongoose.model<IExpenseType>(
  'ExpenseType',
  ExpenseTypeSchema
);

export interface ISystemParam extends Document {
  key: string;
  value: string;
  description?: string;
}

const SystemParamSchema = new Schema<ISystemParam>({
  key: { type: String, required: true, unique: true },
  value: { type: String, required: true },
  description: { type: String },
});

export const SystemParam = mongoose.model<ISystemParam>(
  'SystemParam',
  SystemParamSchema
);
